<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>背景透明内容不透明</title>
	</head>
	<body>
		<div class="wrap">
			外层div透明
			<div class="box">内容不透明</div>
		</div>

		<style>
			* {
				margin: 0;
				padding: 0;
			}

			.wrap {
				width: 500px;
				height: 300px;
				background-color: rgba(255, 0, 0, 0.2);
				position: relative;
			}

			.box {
				width: 500px;
				height: 50px;
				line-height: 50px;
				position: absolute;
				top: 50%;
				transform: translate(0, -50%);
				background-color: #000;
				color: #fff;
				text-align: center;
			}
		</style>
	</body>
</html>
